package ca.jsbr.as2js_lib.utils.generic 
{
	/**
	 * ...
	 * @author jsbr [me@jsbr.ca]
	 */
	public class PathUtils 
	{
		static public const TYPE_IMAGE:String = "image";
		static public const TYPE_AUDIO:String = "audio";
		static public const TYPE_VIDEO:String = "video";
		static public const TYPE_XML:String = "xml";
		static public const TYPE_JSON:String = "json";
		
		static public function getExtension(path:String):String
		{
			var arr:Array = path.split('.');
			return arr[arr.length-1];
		}
		
		static public function getFileType(path:String):String
		{
			var ext:String = getExtension(path);
			switch (ext)
			{
				case "jpg":
				case "png":
				case "gif":
				case "webp":
					return TYPE_IMAGE;
				break;
				case "wav":
				case "mp3":
				case "ogg":
					return TYPE_AUDIO;
				case "xml":
				case "rss":
					return TYPE_XML;
				case "json":
					return TYPE_JSON;
				break;
			}
		}
		
		/**
		 * Return the content folder
		 * @param	path
		 * @return
		 */
		static public function getBasePath(path:String):String
		{
			var arr:Array = path.split('/');
			arr.pop();
			return arr.join("/");
		}
	}

}